#!/bin/bash
#========================================================================
# Author: YSLin
# Email: 
# File Name: tr.sh
# Description: 
#    transliterate   
#  
#	 Class	   Description
#	 alnum	   Letters and digits
#	 alpha	   Letters
#	 blank	   Horizontal whitespace
#	 cntrl	   Control characters
#	 digit	   Digits
#	 graph	   Printable characters, not including spaces
#	 lower	   Lowercase letters
#	 print	   Printable characters, including spaces
#	 punct	   Punctuation
#	 space	   Horizontal or vertical whitespace
#	 upper	   Uppercase letters
#	 xdigit	   Hexadecimal digits
# Edit History: 
#   2011-01-14    File created.
#========================================================================

#將特殊符號轉成空白
tr '!?":;\[\]{}(),.\t\n' ' ' < ch15.doc |
#把內容轉小寫
tr 'A-Z' 'a-z' | 
#把多個空白壓縮成一個
tr -s ' '

#Squeezing Out word
echo "feed me" | tr -s 'e'
echo "Shell Programming" | tr -s 'lm'


tr '!?":;\[\]{}(),.\t\n' ' ' < ch15.doc |
tr 'A-Z' 'a-z' | tr -s ' ' | tr ' ' '\n' | sort | uniq -c |
sort -rn | head

tr '[:punct:]' ' ' < ch15.doc | tr '[:space:]' ' ' |
tr 'A-Z' 'a-z' | tr -s ' ' | tr ' ' '\n' | sort | uniq -c |
sort -rn | head
